<script>
//app.js
// const cloud = require('wx-server-sdk')
// cloud.init({
//   env: cloud.DYNAMIC_CURRENT_ENV
// })
var commonUtils = require("./common/commonUtils.js");
var httpRequest = require("./common/request.js");

export default {
  onLaunch: function () {
    uni.setEnableDebug({
      enableDebug: true
    });
    var that = this;
    uni.getSystemInfo({
      success: function (res) {
        var sdkVersion = res.SDKVersion;
        var versionCompare = commonUtils.compareVersion(sdkVersion, '1.9.90');

        if (versionCompare == -1) {
          that.globalData.isVersionHigh = false;
        } else {
          that.globalData.isVersionHigh = true;
        }
      }
    });
    this.globalData.loginWx();
  },
  globalData: {
    loginWx: function () {
      // 登录
      uni.login({
        success: res => {// 发送 res.code 到后台换取 openId, sessionKey, unionId
        }
      }); // 获取用户信息

      uni.getSetting({
        success: res => {
          if (res.authSetting['scope.userInfo']) {
            // 已经授权，可以直接调用 getUserInfo 获取头像昵称，不会弹框
            uni.getUserInfo({
              success: res => {
                // 可以将 res 发送给后台解码出 unionId
                this.userInfo = res.userInfo; // 由于 getUserInfo 是网络请求，可能会在 Page.onLoad 之后才返回
                // 所以此处加入 callback 以防止这种情况

                if (this.userInfoReadyCallback) {
                  this.userInfoReadyCallback(res);
                }
              }
            });
          }
        }
      });
    },
    userInfo: null,
    isVersionHigh: false,
		startDate:'',
		endDate:'',
    func: {
      httpRequest: httpRequest.httpRequest,
      dateFormat: commonUtils.dateFormat,
      floatAdd: commonUtils.floatAdd,
      floatSub: commonUtils.floatSub,
      floatDiv: commonUtils.floatDiv,
      floatMul: commonUtils.floatMul,
      compareVersion: commonUtils.compareVersion // loginWx: this.loginWx,

    }
  },
  methods: {}
};
</script>
<style>
/**app.wxss**/

.container {
     height: 100%;
     display: flex;
     flex-direction: column;
     align-items: center;
     justify-content: space-between;
     padding: 200rpx 0;
     box-sizing: border-box;
}

.vercialLine {
     width: 1px;
     height: 100%;
     background: #ccc;
}

.horizontalLine {
     height: 1px;
     background: #ccc;
}

.commonBtn, .commonBtnHover {
     display: block;
     color: white;
     font-size: 32rpx;
     padding: 10px;
     border-radius: 5px;
     margin: 40rpx;
     text-align: center;
}

.commonBtn {
     background: #fd7a33;
}

.commonBtnHover {
     background: #e55507;
}

.common_search_input {
     display: flex;
     flex: 1;
     margin: 16rpx;
     padding: 8rpx 14rpx 8rpx 8rpx;
     font-size: 24rpx;
     border-radius: 16rpx;
     border: 1rpx solid gray;
     align-items: center;
     background: white;
}

.common_search_img {
     width: 32rpx;
     height: 32rpx;
     vertical-align: center;
}

.header_tab {
     display: flex;
     flex-direction: row;
     background-color: white;
}

.header_tab .tab_item_default {
     flex: 1;
     padding: 16rpx;
     font-size: 24rpx;
     text-align: center;
     color: black;
     border-bottom: 2px solid #dedede;
}

.header_tab .tab_item_selected {
     flex: 1;
     padding: 16rpx;
     font-size: 24rpx;
     text-align: center;
     color: #ff7676;
     border-bottom: 2px solid #ff7676;
}

.empty_view {
     width: 100%;
     height: 100%;
     box-sizing: border-box;
     display: flex;
     flex-direction: column;
     justify-content: center;
     align-content: center;
}

.empty_icon {
     width: 100rpx;
     height: 100rpx;
     margin: 0 auto;
}

.loading {
     width: 60rpx;
     height: 60rpx;
}

.loadmore {
     width: 100%;
     height: 100rpx;
     font-size: 28rpx;
     background-color: #eee;
     color: gray;
     display: flex;
     flex-direction: row;
     align-items: center;
     justify-content: center;
}

.viewHidden {
     display: none;
}

</style>